import { S } from '../s';
import { IPSAppMethodDTO } from './ipsapp-method-dto';
import { IPSAppMethodDTOField } from './ipsapp-method-dtofield';
import { IPSApplication } from './ipsapplication';
import { IPSAppDEMethodDTO } from './dataentity/ipsapp-demethod-dto';
import { IPSAppDataEntity } from './dataentity/ipsapp-data-entity';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSAppMethodDTOFieldImpl
  extends PSModelObjectImpl
  implements IPSAppMethodDTOField
{
  get codeName(): string {
    return this.M.codeName;
  }

  get jsonFormat(): string {
    return this.M.jsonFormat;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  protected refpsappdemethoddto: IPSAppDEMethodDTO;
  getRefPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    if (this.refpsappdemethoddto != null) return this.refpsappdemethoddto;
    const value = this.M.getRefPSAppDEMethodDTO;
    if (value == null) {
      return;
    }
    this.refpsappdemethoddto =
      this.getRefPSAppDataEntity().findPSAppDEMethodDTO(value);
    return this.refpsappdemethoddto;
  }

  protected refpsappdataentity: IPSAppDataEntity;
  getRefPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.refpsappdataentity ||
      (this.refpsappdataentity = this.fillObjectModel(
        S._f,
        this.M.getRefPSAppDataEntity,
        S._3ce,
      ) as IPSAppDataEntity)
    );
  }

  protected refpsappmethoddto: IPSAppMethodDTO;
  getRefPSAppMethodDTO(): IPSAppMethodDTO | null {
    if (this.refpsappmethoddto != null) return this.refpsappmethoddto;
    const value = this.M.getRefPSAppMethodDTO;
    if (value == null) {
      return;
    }
    const ipsapplication = this.getParentPSModelObject(
      S._26e,
    ) as IPSApplication;
    if (ipsapplication != null) {
      this.refpsappmethoddto = ipsapplication.findPSAppMethodDTO(value);
    }
    return this.refpsappmethoddto;
  }

  get sourceType():
    | 'DEFIELD'
    | 'DEFGROUPDETAIL'
    | 'DER'
    | 'DYNAMODELATTR'
    | 'DEACTIONPARAM'
    | 'DEFSEARCHMODE'
    | 'DEDATASETPARAM' {
    return this.M.sourceType;
  }

  get stdDataType():
    | 0
    | 1
    | 2
    | 3
    | 4
    | 5
    | 6
    | 7
    | 8
    | 9
    | 10
    | 11
    | 12
    | 13
    | 14
    | 15
    | 16
    | 17
    | 18
    | 19
    | 20
    | 21
    | 22
    | 23
    | 24
    | 25
    | 26
    | 27
    | 28
    | 29 {
    return this.M.stdDataType != null ? this.M.stdDataType : 0;
  }

  get type(): 'SIMPLE' | 'SIMPLES' | 'DTO' | 'DTOS' {
    return this.M.type;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty != null ? this.M.allowEmpty : true;
  }
  get cls(): string {
    return 'PSAppMethodDTOFieldImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._3e7) return true;
    return super.instanceof(cls);
  }
}
